<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.css">
    <script src="../jquery/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="../css/style.css">

    <style>
        .red{
            color:red;
        }
    </style>

</head>
<body style="background:url('../images/newres.jpg') no-repeat; background-size:100% 70% ">
<!--<header>-->
<!--    <nav class="navbar navbar-default navbar-inverse">-->
<!--        <div class="container">-->
<!--            <div class="navbar-header">-->
<!--                <a href="#" class="nav-brand">-->
<!--                    <img src="../images/logo1.png" width="220" height="60">-->
<!--                </a>-->
<!--            </div>-->

<!--        </div>-->
<!--    </nav>-->
<!--</header>-->
<section>
    <div class="contacts" >
        <div class="container">
            <div class="row">
                <div class="col-md-3"></div>
                <div class="col-md-6 " style="margin-top:50px;margin-bottom:50px;background-color: rgba(0,0,0,0.2);border: none">
                    <div class="new-title">
                        <div class="row" style="padding-top: 50px">
                            <div class="text-center col-xs-6  col-xs-offset-3"><h2>Register</h2></div>
                        </div>

                            <div class="row contacts-inpt" >
                                <div class="row" style="padding-top: 50px">
                                    <div class="col-xs-6 col-xs-offset-3"><input type="text" class="form-control" id="u_name"  placeholder="用户名/username"></div>
                                </div>
                            </div>
                            <div class="row contacts-inpt">
                                <div class="row" style="padding-top: 30px;">
                                    <div class="col-md-6 col-xs-offset-3"><input type="password" class="form-control" id="u_pwd1" placeholder="登录密码/login password"></div>
                                </div>
                            </div>
                            <div class="row contacts-inpt">
                                <div class="row" style="padding-top: 30px;">
                                    <div class="col-md-6 col-xs-offset-3"><input type="password" class="form-control" id="u_pwd2" placeholder="确认密码/confirm password"></div>
                                </div>
                            </div>


                        <div class="panel-info text-center" style="padding-top: 20px;">
                            <button  class="btn btn-info btn-primary-outline col-md-6 col-md-offset-3" id="registerbtn">注册</button>
                        </div>
                        <div class="row panel-info col-md-offset-5" >
                            <button  class="btn btn-link " id="gotoLogin">去登录</button>
                        </div>
                        <div class="col-md-8 col-md-offset-3" style="padding-bottom: 50px;padding-top: 20px">
                            <input type="checkbox" id="check">
                            我同意<a href="/gotoyhtiaozhuan">账户隐私政策 与 账户cookie政策</a>
                        </div>
                        <div class="row">
                            <div class="col-md-6 col-md-offset-2">
                                <label class="red hidden col-md-offset-2" id="errorLog">登录错误</label>
                            </div>

                        </div>

                    </div>

                </div>
                <div class="col-md-3"></div>
            </div>
        </div>
    </div>

</section>
<footer>
    <div class="nav-list">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-2 col-xs-1">
                    <h4>关于公司</h4>
                    <ul>
                        <li><a href="#">企业简介</a></li>
                        <li><a href="#">品牌简介</a></li>
                        <li><a href="#">品牌荣盛</a></li>
                        <li><a href="#">品牌文化</a></li>
                    </ul>
                </div>
                <div class="col-md-2 col-xs-1">
                    <h4>订单服务</h4>
                    <ul>
                        <li><a href="#">购买指南</a></li>
                        <li><a href="#">支付方式</a></li>
                        <li><a href="#">合作物流</a></li>
                        <li><a href="#">发货时间</a></li>
                    </ul>
                </div>
                <div class="col-md-2 col-xs-1">
                    <h4>服务支持</h4>
                    <ul>
                        <li><a href="#">售后服务</a></li>
                        <li><a href="#">申请退换</a></li>
                        <li><a href="#">上门服务</a></li>
                        <li><a href="#">授权商家</a></li>
                    </ul>
                </div>
                <div class="col-md-2 col-xs-1">
                    <h4>关于我们</h4>
                    <ul>
                        <li><a href="#">人才理念</a></li>
                        <li><a href="#">经营理念</a></li>
                        <li><a href="#">联系方式</a></li>
                        <li><a href="#">集团战略</a></li>
                    </ul>
                </div>
                <div class="col-md-2 col-xs-1">
                    <h4>新闻中心</h4>
                    <ul>
                        <li><a href="#">研发中心</a></li>
                        <li><a href="#">行业新闻</a></li>
                        <li><a href="#">最新资讯</a></li>
                        <li><a href="#">国际时报</a></li>
                    </ul>
                </div>
                <div class="col-md-2 col-xs-2">
                    <div class="abtn workdate">
                        <a href="#" class="text-center">联系客服</a>
                    </div>
                    <h3>952 952-9527</h3>
                    <p >周一至周日9:00-18:00(节假日除外)</p>
                </div>
            </div>
        </div>
    </div>
    <div class="copryright">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-8 col-xs-4 col-md-offset-2 col-xs-offset-4">
                    <span class="copry">Copryright 2020 软件人-卓越第九小组 all right Reserved 卓越第九小组工作室 </span>
                    <a href="#">| 法律声明 | 隐私条款</a>
                    <p class="copry">粤备xxxxxxx号  公安备xxxxxx号</p>
                </div>
            </div>
        </div>
    </div>
</footer>
<script>
    var yhpwd=null;
$(document).ready(function () {
    $("#u_pwd2").blur(function () {
        var pwd1= $("#u_pwd1").val();
        var pwd2= $("#u_pwd2").val();

        if($("#check").is(':checked')){
            if(pwd1 != pwd2){
                $("#errorLog").text("两次密码输入不一致");
                $("#errorLog").removeClass("hidden");
            }else{
                yhpwd=pwd1;
                $("#errorLog").addClass("hidden");
            }
        }else {
            alert("请同意账户隐私政策 与 账户cookie政策")
        }

    });
        $("#registerbtn").click(function () {
            $.ajax({
                url:"user/insert",
                type:"post",
                async:true,
                dataType:"json",
                data:{

                    u_name:$("#u_name").val(),
                    u_pwd:yhpwd,

                },
                //result封装成立json对象，解析result.
                success:function (result) {
                    var errorCode = result.errorCode;
                    // alert(JSON.stringify(result));

                        if(errorCode==0){
                            alert("注册成功");
                            $(location).attr("href","gotoLogin");
                        }else{
                            var msg = result.status;
                            $("#u_pwd").val("");
                            // alert(msg);
                            $("#errorLog").text(msg);
                            $("#errorLog").removeClass("hidden");
                        }

                },
                error:function (result) {

                }
            })
        });

    $("#gotoLogin").click(function () {
        $(location).attr("href","gotoLogin");
    });

    $("#u_name").blur(function () {
        $.ajax({
            url:"user/checkUserNameExist",
            type:"post",
            dataType:"json",
            data:{
                u_name:$("#u_name").val(),

            },
            //result封装成立json对象，解析result.
            success:function (result) {
                var errorCode = result.errorCode;
                // alert(JSON.stringify(result));
                if(errorCode==-1){
                    var msg = result.status;
                    $("#errorLog").text(msg);
                    $("#errorLog").removeClass("hidden");
                    $("#u_name").val("");
                }else if(errorCode==0){
                    $("#errorLog").addClass("hidden");
                }
            },
            error:function (result) {

            }
        })
    });


        })


</script>
</body>
</html>